package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.entity.dto.order.OrderSaveDto;
import com.itheima.entity.vo.order.OrderUserPageVo;
import com.itheima.mapper.OrderMapper;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author huangzelnag
 * @create 2022-05-20
 */
@RestController
@RequestMapping("order/")
public class OrderController {
    @Autowired
    OrderService orderService;

    /**
     * 提交订单
     * @param orderSaveDto
     * @return
     */
    @PostMapping("submit")
    public R saveOrder(@RequestBody OrderSaveDto orderSaveDto){


   Boolean flag =     orderService.saveOrder(orderSaveDto);


        return R.success("");
    }


    /**
     * 获取用户订单分页
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("userPage")
    public R getOrderUserPage(@RequestParam Integer page,
                              @RequestParam Integer pageSize){

        OrderUserPageVo orderUserPageVo = orderService.getOrderUserPage(page,pageSize);

        return R.success(orderUserPageVo);
    }




}
